{extend name="admininfo/admininfo" /}
{block name='main'}
<form class="form-horizontal" action="{:url('admin/Specials/update')}" method='post' enctype="multipart/form-data">
    <input type="hidden" value="{$data['id']}" name='id'>
    <div class="modal-body">

        <table class="table table-bordered" >
            <tr>
                <td>专辑名</td>
                <td><input type="text" name='name' value="{$data['name']}"></td>
            </tr>
            <tr>
                <td>演唱歌手</td>
                <td><input type="text" id='singer' name='singer' value="{$data['singer']}"></td>
            </tr>
            <tr>
                <td>所属地区</td>
                <td>
                    <select name="style" id="">
                        {foreach $res as $k => $v}
                        <optgroup label="{$k}">

                        {foreach $v as $a => $b}
                        <option value="{$b}" {if $data.style == $b} selected  {/if}>{$b}</option>

                        {/foreach}
                        {/foreach} 
                    </select>
                </td>
            </tr>
            <tr>
                <td>描述</td>
                <td>
                    <textarea name="dsc" id="" cols="30" rows="10" >{$data['dc']}</textarea>
                </td>
            </tr>
            <tr>

                <td colspan="2" style="text-align:center">
                    <button class="btn btn-primary adds" type='submit'>
                        更新数据
                    </button>               
                    
                </td>
            </tr>
        </form>
        <form action="../../updateimg" enctype="multipart/form-data" method="post">
            <input type="hidden" value="{$data['id']}" name='id'>
            
            <tr>
                <td>图片</td>
                <td><input type="file" name='image'></td>
            </tr>
            <tr>
                <td colspan="2" style="text-align:center">
                    <input type="submit" value='更新图片' class="btn btn-primary adds">
                </td>
            </tr>
        </form>
        
        </table>
    </div>





<script>
    //添加专辑是获取歌手
    $("#singer").blur(function(){
        var singer = $('#singer').val();
        $.ajax({
            type:'post',
            url:  '../../singer',
            data:{ 'singer': singer },
            dataType:'json',
            success:function(data){
                // console.log($(this).parents('tr').remove());
                if (data===null) {
                    // $("#singer").css("border","1px solid red");
                    var HTM = "<b style='color:red'>数据库无此歌手请添加</b>"
                    $('#singer').after(HTM)
                }

            }

        })

    });

    $("#singer").focus(function(){
        $('#singer').next().remove()
    });
</script>

{/block}